/**
 * Created by zhoua on 2016/12/18.
 */
var kygsListVm = new Vue({
    el:'#kygsList_vm',
    data: {
        toggle : 1,    // 显示项 1.显示正在加载 2.显示数据 3显示暂无数据
        infoList:[],
        totalRow:1,
        monthData:''
    }
});

var row = 10;
function getVmList(curr,page,vm,pagination,argu,type) {
    $.ajax({
        url: '/kfqCommonService/api/gz/lg/exceptionDir/countList.v',
        type: "POST",
        dataType: "json",
        data: {
            custNameLike:argu.custNameLike || "",
            type:type
        },
        error: function () {
            vm.toggle = 3;
        }
    }).done(function (data) {
        console.log(data);
        if (data.status == '200') {
            if (data.data.dataList.length > 0) {
                vm.toggle = 2;
                vm.infoList = data.data.dataList;
                vm.totalRow = data.data.pageObj.totalRow;
                laypage({
                    cont: pagination, //容器。值支持id名、原生dom对象，jquery对象。【如该容器为】：<div id="page1"></div>
                    pages: Math.ceil(vm.totalRow / row), //通过后台拿到的总页数
                    curr: curr || 1, //当前页
                    first: 1, //将首页显示为数字1,。若不显示，设置false即可
                    last: Math.ceil(vm.totalRow / row), //将尾页显示为总页数。若不显示，设置false即可
                    skin: '#21b573',
                    jump: function (obj, first) { //触发分页后的回调
                        if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
                            getVmList(obj.curr,page,vm,pagination,{},type);

                        }
                    }
                });

            } else {
                vm.toggle = 3;
            }
        } else {
            vm.toggle = 3;
        }
    });
}
$.ajax({
    url: '/kfqCommonService/api/gz/lg/exceptionDir/countList.v',
    type: "POST",
    dataType: "json",
    data: {
        type: "month"
    },
    error: function () {
        kygsListVm.toggle = 3;
    }
}).done(function (data) {
    kygsListVm.monthData = data.data.pageObj.totalRow;
});

getVmList(1, 10, kygsListVm, $("#pagination_page"),{},'oths');
//搜索
$("#searBtn").on("click", function () {
    var custName = $("#searText").val();
    getVmList(1, 10, kygsListVm, $("#pagination_page"), {custNameLike: custName},'oths');
});